use crate::event::KeyCode;

pub fn translate_keycode(keycode: u32) -> KeyCode {
    // same as GLFW
    match keycode {
        0x01 => KeyCode::Left,
        0x02 => KeyCode::Right,
        0x03 => KeyCode::Home,
        0x04 => KeyCode::Back,
        0x07 => KeyCode::Key0,
        0x08 => KeyCode::Key1,
        0x09 => KeyCode::Key2,
        0x0a => KeyCode::Key3,
        0x0b => KeyCode::Key4,
        0x0c => KeyCode::Key5,
        0x0d => KeyCode::Key6,
        0x0e => KeyCode::Key7,
        0x0f => KeyCode::Key8,
        0x10 => KeyCode::Key9,
        0x13 => KeyCode::Up,
        0x14 => KeyCode::Down,
        0x15 => KeyCode::Left,
        0x16 => KeyCode::Right,
        0x17 => KeyCode::Enter,
        0x1d => KeyCode::A,
        0x1e => KeyCode::B,
        0x1f => KeyCode::C,
        0x20 => KeyCode::D,
        0x21 => KeyCode::E,
        0x22 => KeyCode::F,
        0x23 => KeyCode::G,
        0x24 => KeyCode::H,
        0x25 => KeyCode::I,
        0x26 => KeyCode::J,
        0x27 => KeyCode::K,
        0x28 => KeyCode::L,
        0x29 => KeyCode::M,
        0x2a => KeyCode::N,
        0x2b => KeyCode::O,
        0x2c => KeyCode::P,
        0x2d => KeyCode::Q,
        0x2e => KeyCode::R,
        0x2f => KeyCode::S,
        0x30 => KeyCode::T,
        0x31 => KeyCode::U,
        0x32 => KeyCode::V,
        0x33 => KeyCode::W,
        0x34 => KeyCode::X,
        0x35 => KeyCode::Y,
        0x36 => KeyCode::Z,
        0x37 => KeyCode::Comma,
        0x38 => KeyCode::Period,
        0x39 => KeyCode::LeftAlt,
        0x3a => KeyCode::RightAlt,
        0x3b => KeyCode::LeftShift,
        0x3c => KeyCode::RightShift,
        0x3d => KeyCode::Tab,
        0x3e => KeyCode::Space,
        0x42 => KeyCode::Enter,
        // android calls it Delete, but it has an icon of the Backspace and
        // expected behavior of the Backspace
        0x43 => KeyCode::Backspace,
        _ => KeyCode::Unknown,
    }
}
